#include "conmap.h"
#include "string/str.h"

template class mztool::ConMap<mztool::String, mztool::String>;
template class mztool::ConMap<std::string, mztool::String>;
template class mztool::ConMap<mztool::String, std::string>;
template class mztool::ConMap<int, mztool::String>;
template class mztool::ConMap<mztool::String, int>;

template<typename _Key, typename _Val>
void mztool::ConMap<_Key, _Val>::Put(_Key key, _Val val)
{
    std::shared_lock lock(m_mutex);
    this->m_data.insert({key, val});
}

template<typename _Key, typename _Val>
bool mztool::ConMap<_Key, _Val>::Get(_Key key, _Val& val)
{
    std::shared_lock lock(m_mutex);
    auto it = this->m_data.find(key);
    if (it == this->m_data.end()){
        return false;
    }
    val = it->second;
    return true;
}

template<typename _Key, typename _Val>
int mztool::ConMap<_Key, _Val>::Size()
{
    return m_data.size();
}